<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class URI::Generic - uri: Ruby Standard Library Documentation</title>


<script src="../js/navigation.js" defer></script>
<script src="../js/search.js" defer></script>
<script src="../js/search_index.js" defer></script>
<script src="../js/searcher.js" defer></script>
<script src="../js/darkfish.js" defer></script>

<script src="../js/jquery-3.2.0.min.js"></script>

<script src="../js/vue.min.js"></script>
<script src="../js/js.cookie.min.js"></script>

<link href="../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../css/rdoc.css" rel="stylesheet">
<link href="../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../";
  var index_rel_prefix = "../";
  var darkModeCsseHref = "../css/rdoc-dm.css"
  var defaultModeCssHref = "../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../table_of_contents.html#pages">Pages</a>
    <a href="../table_of_contents.html#classes">Classes</a>
    <a href="../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link">Object
</div>

        
<div id="includes-section" class="nav-section">
  <h3>Included Modules</h3>

  <ul class="link-list">
    <li><a class="include" href="../URI.html">URI</a>
  </ul>
</div>

        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-build">::build</a>
    <li ><a href="#method-c-build2">::build2</a>
    <li ><a href="#method-c-component">::component</a>
    <li ><a href="#method-c-default_port">::default_port</a>
    <li ><a href="#method-c-new">::new</a>
    <li ><a href="#method-i-2B">#+</a>
    <li ><a href="#method-i-2D">#-</a>
    <li ><a href="#method-i-3D-3D">#==</a>
    <li ><a href="#method-i-absolute">#absolute</a>
    <li ><a href="#method-i-absolute-3F">#absolute?</a>
    <li ><a href="#method-i-check_host">#check_host</a>
    <li ><a href="#method-i-check_opaque">#check_opaque</a>
    <li ><a href="#method-i-check_password">#check_password</a>
    <li ><a href="#method-i-check_path">#check_path</a>
    <li ><a href="#method-i-check_port">#check_port</a>
    <li ><a href="#method-i-check_scheme">#check_scheme</a>
    <li ><a href="#method-i-check_user">#check_user</a>
    <li ><a href="#method-i-check_userinfo">#check_userinfo</a>
    <li class="calls-super" ><a href="#method-i-coerce">#coerce</a>
    <li ><a href="#method-i-component">#component</a>
    <li ><a href="#method-i-component_ary">#component_ary</a>
    <li ><a href="#method-i-decoded_password">#decoded_password</a>
    <li ><a href="#method-i-decoded_user">#decoded_user</a>
    <li ><a href="#method-i-default_port">#default_port</a>
    <li ><a href="#method-i-eql-3F">#eql?</a>
    <li ><a href="#method-i-escape_userpass">#escape_userpass</a>
    <li ><a href="#method-i-find_proxy">#find_proxy</a>
    <li ><a href="#method-i-fragment-3D">#fragment=</a>
    <li ><a href="#method-i-hash">#hash</a>
    <li ><a href="#method-i-hierarchical-3F">#hierarchical?</a>
    <li ><a href="#method-i-host-3D">#host=</a>
    <li ><a href="#method-i-hostname">#hostname</a>
    <li ><a href="#method-i-hostname-3D">#hostname=</a>
    <li ><a href="#method-i-inspect">#inspect</a>
    <li ><a href="#method-i-merge">#merge</a>
    <li ><a href="#method-i-merge-21">#merge!</a>
    <li ><a href="#method-i-merge_path">#merge_path</a>
    <li ><a href="#method-i-normalize">#normalize</a>
    <li ><a href="#method-i-normalize-21">#normalize!</a>
    <li ><a href="#method-i-opaque-3D">#opaque=</a>
    <li ><a href="#method-i-parser">#parser</a>
    <li ><a href="#method-i-password">#password</a>
    <li ><a href="#method-i-password-3D">#password=</a>
    <li ><a href="#method-i-path-3D">#path=</a>
    <li ><a href="#method-i-port-3D">#port=</a>
    <li ><a href="#method-i-query-3D">#query=</a>
    <li ><a href="#method-i-registry-3D">#registry=</a>
    <li ><a href="#method-i-relative-3F">#relative?</a>
    <li ><a href="#method-i-replace-21">#replace!</a>
    <li ><a href="#method-i-route_from">#route_from</a>
    <li ><a href="#method-i-route_to">#route_to</a>
    <li ><a href="#method-i-scheme-3D">#scheme=</a>
    <li ><a href="#method-i-select">#select</a>
    <li ><a href="#method-i-set_host">#set_host</a>
    <li ><a href="#method-i-set_opaque">#set_opaque</a>
    <li ><a href="#method-i-set_password">#set_password</a>
    <li ><a href="#method-i-set_path">#set_path</a>
    <li ><a href="#method-i-set_port">#set_port</a>
    <li ><a href="#method-i-set_scheme">#set_scheme</a>
    <li ><a href="#method-i-set_user">#set_user</a>
    <li ><a href="#method-i-set_userinfo">#set_userinfo</a>
    <li ><a href="#method-i-split_path">#split_path</a>
    <li ><a href="#method-i-split_userinfo">#split_userinfo</a>
    <li ><a href="#method-i-to_s">#to_s</a>
    <li ><a href="#method-i-user">#user</a>
    <li ><a href="#method-i-user-3D">#user=</a>
    <li ><a href="#method-i-userinfo">#userinfo</a>
    <li ><a href="#method-i-userinfo-3D">#userinfo=</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-URI::Generic">
    <h1 id="class-URI::Generic" class="class">
      class URI::Generic
    </h1>

    <section class="description">
    
<p>Base class for all <a href="../URI.html"><code>URI</code></a> classes. Implements generic <a href="../URI.html"><code>URI</code></a> syntax as per RFC 2396.</p>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">


      <section class="constants-list">
      <header>
      <h3>Constants</h3>
      </header>
      <dl>
          <dt id="COMPONENT">COMPONENT
          <dd><p>An Array of the available components for <a href="Generic.html"><code>URI::Generic</code></a>.</p>
          <dt id="DEFAULT_PORT">DEFAULT_PORT
          <dd><p>A Default port of nil for <a href="Generic.html"><code>URI::Generic</code></a>.</p>
        </dl>
        </section>

        <section class="attribute-method-details" class="method-section">
        <header>
        <h3>Attributes</h3>
        </header>

          <div id="attribute-i-fragment" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">fragment</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              <p>Returns the fragment component of the <a href="../URI.html"><code>URI</code></a>.</p>

<pre class="ruby"><span class="ruby-constant">URI</span>(<span class="ruby-string">&quot;http://foo/bar/baz?search=FooBar#ponies&quot;</span>).<span class="ruby-identifier">fragment</span> <span class="ruby-comment">#=&gt; &quot;ponies&quot;</span>
</pre>
              </div>
            </div>
          <div id="attribute-i-host" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">host</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              <p>Returns the host component of the <a href="../URI.html"><code>URI</code></a>.</p>

<pre class="ruby"><span class="ruby-constant">URI</span>(<span class="ruby-string">&quot;http://foo/bar/baz&quot;</span>).<span class="ruby-identifier">host</span> <span class="ruby-comment">#=&gt; &quot;foo&quot;</span>
</pre>

<p>It returns nil if no host component exists.</p>

<pre class="ruby"><span class="ruby-constant">URI</span>(<span class="ruby-string">&quot;mailto:foo@example.org&quot;</span>).<span class="ruby-identifier">host</span> <span class="ruby-comment">#=&gt; nil</span>
</pre>

<p>The component does not contain the port number.</p>

<pre class="ruby"><span class="ruby-constant">URI</span>(<span class="ruby-string">&quot;http://foo:8080/bar/baz&quot;</span>).<span class="ruby-identifier">host</span> <span class="ruby-comment">#=&gt; &quot;foo&quot;</span>
</pre>

<p>Since IPv6 addresses are wrapped with brackets in URIs, this method returns IPv6 addresses wrapped with brackets. This form is not appropriate to pass to socket methods such as TCPSocket.open. If unwrapped host names are required, use the <a href="Generic.html#method-i-hostname"><code>hostname</code></a> method.</p>

<pre class="ruby"><span class="ruby-constant">URI</span>(<span class="ruby-string">&quot;http://[::1]/bar/baz&quot;</span>).<span class="ruby-identifier">host</span>     <span class="ruby-comment">#=&gt; &quot;[::1]&quot;</span>
<span class="ruby-constant">URI</span>(<span class="ruby-string">&quot;http://[::1]/bar/baz&quot;</span>).<span class="ruby-identifier">hostname</span> <span class="ruby-comment">#=&gt; &quot;::1&quot;</span>
</pre>
              </div>
            </div>
          <div id="attribute-i-opaque" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">opaque</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              <p>Returns the opaque part of the <a href="../URI.html"><code>URI</code></a>.</p>

<pre class="ruby"><span class="ruby-constant">URI</span>(<span class="ruby-string">&quot;mailto:foo@example.org&quot;</span>).<span class="ruby-identifier">opaque</span> <span class="ruby-comment">#=&gt; &quot;foo@example.org&quot;</span>
<span class="ruby-constant">URI</span>(<span class="ruby-string">&quot;http://foo/bar/baz&quot;</span>).<span class="ruby-identifier">opaque</span>     <span class="ruby-comment">#=&gt; nil</span>
</pre>

<p>The portion of the path that does not make use of the slash ‘/’. The path typically refers to an absolute path or an opaque part. (See RFC2396 Section 3 and 5.2.)</p>
              </div>
            </div>
          <div id="attribute-i-path" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">path</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              <p>Returns the path component of the <a href="../URI.html"><code>URI</code></a>.</p>

<pre class="ruby"><span class="ruby-constant">URI</span>(<span class="ruby-string">&quot;http://foo/bar/baz&quot;</span>).<span class="ruby-identifier">path</span> <span class="ruby-comment">#=&gt; &quot;/bar/baz&quot;</span>
</pre>
              </div>
            </div>
          <div id="attribute-i-port" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">port</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              <p>Returns the port component of the <a href="../URI.html"><code>URI</code></a>.</p>

<pre class="ruby"><span class="ruby-constant">URI</span>(<span class="ruby-string">&quot;http://foo/bar/baz&quot;</span>).<span class="ruby-identifier">port</span>      <span class="ruby-comment">#=&gt; 80</span>
<span class="ruby-constant">URI</span>(<span class="ruby-string">&quot;http://foo:8080/bar/baz&quot;</span>).<span class="ruby-identifier">port</span> <span class="ruby-comment">#=&gt; 8080</span>
</pre>
              </div>
            </div>
          <div id="attribute-i-query" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">query</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              <p>Returns the query component of the <a href="../URI.html"><code>URI</code></a>.</p>

<pre class="ruby"><span class="ruby-constant">URI</span>(<span class="ruby-string">&quot;http://foo/bar/baz?search=FooBar&quot;</span>).<span class="ruby-identifier">query</span> <span class="ruby-comment">#=&gt; &quot;search=FooBar&quot;</span>
</pre>
              </div>
            </div>
          <div id="attribute-i-scheme" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">scheme</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              <p>Returns the scheme component of the <a href="../URI.html"><code>URI</code></a>.</p>

<pre class="ruby"><span class="ruby-constant">URI</span>(<span class="ruby-string">&quot;http://foo/bar/baz&quot;</span>).<span class="ruby-identifier">scheme</span> <span class="ruby-comment">#=&gt; &quot;http&quot;</span>
</pre>
              </div>
            </div>
            </section>


                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-build" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">build</span><span
                                class="method-args">(args)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <h2 id="method-c-build-label-Synopsis">Synopsis<span><a href="#method-c-build-label-Synopsis">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>See <a href="Generic.html#method-c-new"><code>::new</code></a>.</p>

<h2 id="method-c-build-label-Description">Description<span><a href="#method-c-build-label-Description">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>Creates a new <a href="Generic.html"><code>URI::Generic</code></a> instance from components of <a href="Generic.html"><code>URI::Generic</code></a> with check.  Components are: scheme, userinfo, host, port, registry, path, opaque, query, and fragment. You can provide arguments either by an Array or a Hash. See <a href="Generic.html#method-c-new"><code>::new</code></a> for hash keys to use or for order of array items.</p>

                              <div class="method-source-code" id="build-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 116</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">build</span>(<span class="ruby-identifier">args</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Array</span>) <span class="ruby-operator">&amp;&amp;</span>
      <span class="ruby-identifier">args</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-operator">::</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">Generic</span><span class="ruby-operator">::</span><span class="ruby-constant">COMPONENT</span>.<span class="ruby-identifier">size</span>
    <span class="ruby-identifier">tmp</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">dup</span>
  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Hash</span>)
    <span class="ruby-identifier">tmp</span> = <span class="ruby-operator">::</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">Generic</span><span class="ruby-operator">::</span><span class="ruby-constant">COMPONENT</span>.<span class="ruby-identifier">collect</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span>
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">c</span>)
        <span class="ruby-identifier">args</span>[<span class="ruby-identifier">c</span>]
      <span class="ruby-keyword">else</span>
        <span class="ruby-keyword">nil</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">component</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">component</span> <span class="ruby-keyword">rescue</span> <span class="ruby-operator">::</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">Generic</span><span class="ruby-operator">::</span><span class="ruby-constant">COMPONENT</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>,
    <span class="ruby-node">&quot;expected Array of or Hash of components of #{self.class} (#{component.join(&#39;, &#39;)})&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">tmp</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">tmp</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-keyword">true</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">new</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">tmp</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-build2" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">build2</span><span
                                class="method-args">(args)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <h2 id="method-c-build2-label-Synopsis">Synopsis<span><a href="#method-c-build2-label-Synopsis">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>See <a href="Generic.html#method-c-new"><code>::new</code></a>.</p>

<h2 id="method-c-build2-label-Description">Description<span><a href="#method-c-build2-label-Description">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>At first, tries to create a new <a href="Generic.html"><code>URI::Generic</code></a> instance using <a href="Generic.html#method-c-build"><code>URI::Generic::build</code></a>. But, if exception <a href="InvalidComponentError.html"><code>URI::InvalidComponentError</code></a> is raised, then it does URI::Escape.escape all <a href="../URI.html"><code>URI</code></a> components and tries again.</p>

                              <div class="method-source-code" id="build2-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 78</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">build2</span>(<span class="ruby-identifier">args</span>)
  <span class="ruby-keyword">begin</span>
    <span class="ruby-keyword">return</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">build</span>(<span class="ruby-identifier">args</span>)
  <span class="ruby-keyword">rescue</span> <span class="ruby-constant">InvalidComponentError</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Array</span>)
      <span class="ruby-keyword">return</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">build</span>(<span class="ruby-identifier">args</span>.<span class="ruby-identifier">collect</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span>
        <span class="ruby-keyword">if</span> <span class="ruby-identifier">x</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">String</span>)
          <span class="ruby-constant">DEFAULT_PARSER</span>.<span class="ruby-identifier">escape</span>(<span class="ruby-identifier">x</span>)
        <span class="ruby-keyword">else</span>
          <span class="ruby-identifier">x</span>
        <span class="ruby-keyword">end</span>
      })
    <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Hash</span>)
      <span class="ruby-identifier">tmp</span> = {}
      <span class="ruby-identifier">args</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">tmp</span>[<span class="ruby-identifier">key</span>] = <span class="ruby-keyword">if</span> <span class="ruby-identifier">value</span>
            <span class="ruby-constant">DEFAULT_PARSER</span>.<span class="ruby-identifier">escape</span>(<span class="ruby-identifier">value</span>)
          <span class="ruby-keyword">else</span>
            <span class="ruby-identifier">value</span>
          <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">return</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">build</span>(<span class="ruby-identifier">tmp</span>)
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-component" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">component</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Components of the <a href="../URI.html"><code>URI</code></a> in the order.</p>

                              <div class="method-source-code" id="component-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 57</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">component</span>
  <span class="ruby-keyword">self</span><span class="ruby-operator">::</span><span class="ruby-constant">COMPONENT</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-default_port" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">default_port</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns default port.</p>

                              <div class="method-source-code" id="default_port-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 32</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">default_port</span>
  <span class="ruby-keyword">self</span><span class="ruby-operator">::</span><span class="ruby-constant">DEFAULT_PORT</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-new" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">new</span><span
                                class="method-args">(scheme, userinfo, host, port, registry, path, opaque, query, fragment, parser = DEFAULT_PARSER, arg_check = false)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <h2 id="method-c-new-label-Args">Args<span><a href="#method-c-new-label-Args">&para;</a> <a href="#top">&uarr;</a></span></h2>
<dl class="rdoc-list note-list"><dt><code>scheme</code>
<dd>
<p>Protocol scheme, i.e. ‘http’,‘ftp’,‘mailto’ and so on.</p>
</dd><dt><code>userinfo</code>
<dd>
<p>User name and password, i.e. ‘sdmitry:bla’.</p>
</dd><dt><code>host</code>
<dd>
<p>Server host name.</p>
</dd><dt><code>port</code>
<dd>
<p>Server port.</p>
</dd><dt><code>registry</code>
<dd>
<p>Registry of naming authorities.</p>
</dd><dt><code>path</code>
<dd>
<p>Path on server.</p>
</dd><dt><code>opaque</code>
<dd>
<p>Opaque part.</p>
</dd><dt><code>query</code>
<dd>
<p>Query data.</p>
</dd><dt><code>fragment</code>
<dd>
<p>Part of the <a href="../URI.html"><code>URI</code></a> after ‘#’ character.</p>
</dd><dt><code>parser</code>
<dd>
<p><a href="RFC2396_Parser.html"><code>Parser</code></a> for internal use [URI::DEFAULT_PARSER by default].</p>
</dd><dt><code>arg_check</code>
<dd>
<p>Check arguments [false by default].</p>
</dd></dl>

<h2 id="method-c-new-label-Description">Description<span><a href="#method-c-new-label-Description">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>Creates a new <a href="Generic.html"><code>URI::Generic</code></a> instance from “generic” components without check.</p>

                              <div class="method-source-code" id="new-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 169</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">scheme</span>,
               <span class="ruby-identifier">userinfo</span>, <span class="ruby-identifier">host</span>, <span class="ruby-identifier">port</span>, <span class="ruby-identifier">registry</span>,
               <span class="ruby-identifier">path</span>, <span class="ruby-identifier">opaque</span>,
               <span class="ruby-identifier">query</span>,
               <span class="ruby-identifier">fragment</span>,
               <span class="ruby-identifier">parser</span> = <span class="ruby-constant">DEFAULT_PARSER</span>,
               <span class="ruby-identifier">arg_check</span> = <span class="ruby-keyword">false</span>)
  <span class="ruby-ivar">@scheme</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-ivar">@user</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-ivar">@password</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-ivar">@host</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-ivar">@port</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-ivar">@path</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-ivar">@query</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-ivar">@opaque</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-ivar">@fragment</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-ivar">@parser</span> = <span class="ruby-identifier">parser</span> <span class="ruby-operator">==</span> <span class="ruby-constant">DEFAULT_PARSER</span> <span class="ruby-operator">?</span> <span class="ruby-keyword">nil</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">parser</span>

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">arg_check</span>
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">scheme</span> = <span class="ruby-identifier">scheme</span>
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">userinfo</span> = <span class="ruby-identifier">userinfo</span>
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">hostname</span> = <span class="ruby-identifier">host</span>
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">port</span> = <span class="ruby-identifier">port</span>
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">path</span> = <span class="ruby-identifier">path</span>
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">query</span> = <span class="ruby-identifier">query</span>
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">opaque</span> = <span class="ruby-identifier">opaque</span>
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">fragment</span> = <span class="ruby-identifier">fragment</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">set_scheme</span>(<span class="ruby-identifier">scheme</span>)
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">set_userinfo</span>(<span class="ruby-identifier">userinfo</span>)
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">set_host</span>(<span class="ruby-identifier">host</span>)
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">set_port</span>(<span class="ruby-identifier">port</span>)
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">set_path</span>(<span class="ruby-identifier">path</span>)
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">query</span> = <span class="ruby-identifier">query</span>
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">set_opaque</span>(<span class="ruby-identifier">opaque</span>)
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">fragment</span>=(<span class="ruby-identifier">fragment</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">registry</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidURIError</span>,
      <span class="ruby-node">&quot;the scheme #{@scheme} does not accept registry part: #{registry} (or bad hostname?)&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-ivar">@scheme</span>&amp;.<span class="ruby-identifier">freeze</span>
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">set_path</span>(<span class="ruby-string">&#39;&#39;</span>) <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-ivar">@path</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-ivar">@opaque</span> <span class="ruby-comment"># (see RFC2396 Section 5.2)</span>
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">set_port</span>(<span class="ruby-keyword">self</span>.<span class="ruby-identifier">default_port</span>) <span class="ruby-keyword">if</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">default_port</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-ivar">@port</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-2B" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">+</span><span
                                class="method-args">(oth)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="Generic.html#method-i-merge">merge</a>
                            </div>
                          </div>

                  <div id="method-i-2D" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">-</span><span
                                class="method-args">(oth)</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="Generic.html#method-i-route_from">route_from</a>
                            </div>
                          </div>

                  <div id="method-i-3D-3D" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">==</span><span
                                class="method-args">(oth)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Compares two URIs.</p>

                              <div class="method-source-code" id="3D-3D-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 1383</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">==</span>(<span class="ruby-identifier">oth</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">oth</span>.<span class="ruby-identifier">class</span>
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">normalize</span>.<span class="ruby-identifier">component_ary</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">oth</span>.<span class="ruby-identifier">normalize</span>.<span class="ruby-identifier">component_ary</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-keyword">false</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-absolute" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">absolute</span><span
                                class="method-args">()</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="Generic.html#method-i-absolute-3F">absolute?</a>
                            </div>
                          </div>

                  <div id="method-i-absolute-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">absolute?</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns true if <a href="../URI.html"><code>URI</code></a> has a scheme (e.g. http:// or https://) specified.</p>

                              <div class="method-source-code" id="absolute-3F-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 972</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">absolute?</span>
  <span class="ruby-keyword">if</span> <span class="ruby-ivar">@scheme</span>
    <span class="ruby-keyword">true</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-keyword">false</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="Generic.html#method-i-absolute">absolute</a>
                            </div>

                          </div>

                  <div id="method-i-coerce" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">coerce</span><span
                                class="method-args">(oth)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <h2 id="method-i-coerce-label-Args">Args<span><a href="#method-i-coerce-label-Args">&para;</a> <a href="#top">&uarr;</a></span></h2>
<dl class="rdoc-list note-list"><dt><code>v</code>
<dd>
<p><a href="../URI.html"><code>URI</code></a> or String</p>
</dd></dl>

<h2 id="method-i-coerce-label-Description">Description<span><a href="#method-i-coerce-label-Description">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>Attempts to parse other <a href="../URI.html"><code>URI</code></a> <code>oth</code>, returns [parsed_oth, self].</p>

<h2 id="method-i-coerce-label-Usage">Usage<span><a href="#method-i-coerce-label-Usage">&para;</a> <a href="#top">&uarr;</a></span></h2>

<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;uri&#39;</span>

<span class="ruby-identifier">uri</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-string">&quot;http://my.example.com&quot;</span>)
<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">coerce</span>(<span class="ruby-string">&quot;http://foo.com&quot;</span>)
<span class="ruby-comment">#=&gt; [#&lt;URI::HTTP http://foo.com&gt;, #&lt;URI::HTTP http://my.example.com&gt;]</span>
</pre>
                                <div class="method-calls-super">
                                  Calls superclass method
                                  
                              </div>

                              <div class="method-source-code" id="coerce-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 1473</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">coerce</span>(<span class="ruby-identifier">oth</span>)
  <span class="ruby-keyword">case</span> <span class="ruby-identifier">oth</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">String</span>
    <span class="ruby-identifier">oth</span> = <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">oth</span>)
  <span class="ruby-keyword">else</span>
    <span class="ruby-keyword">super</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">return</span> <span class="ruby-identifier">oth</span>, <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-component" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">component</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Components of the <a href="../URI.html"><code>URI</code></a> in the order.</p>

                              <div class="method-source-code" id="component-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 313</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">component</span>
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">component</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-decoded_password" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">decoded_password</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the password component after <a href="../URI.html"><code>URI</code></a> decoding.</p>

                              <div class="method-source-code" id="decoded_password-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 583</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">decoded_password</span>
  <span class="ruby-constant">URI</span>.<span class="ruby-identifier">decode_uri_component</span>(<span class="ruby-ivar">@password</span>) <span class="ruby-keyword">if</span> <span class="ruby-ivar">@password</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-decoded_user" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">decoded_user</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the user component after <a href="../URI.html"><code>URI</code></a> decoding.</p>

                              <div class="method-source-code" id="decoded_user-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 578</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">decoded_user</span>
  <span class="ruby-constant">URI</span>.<span class="ruby-identifier">decode_uri_component</span>(<span class="ruby-ivar">@user</span>) <span class="ruby-keyword">if</span> <span class="ruby-ivar">@user</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-default_port" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">default_port</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns default port.</p>

                              <div class="method-source-code" id="default_port-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 39</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">default_port</span>
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">default_port</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-eql-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">eql?</span><span
                                class="method-args">(oth)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="eql-3F-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 1395</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">eql?</span>(<span class="ruby-identifier">oth</span>)
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">oth</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">&amp;&amp;</span>
  <span class="ruby-identifier">parser</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">oth</span>.<span class="ruby-identifier">parser</span> <span class="ruby-operator">&amp;&amp;</span>
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">component_ary</span>.<span class="ruby-identifier">eql?</span>(<span class="ruby-identifier">oth</span>.<span class="ruby-identifier">component_ary</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-find_proxy" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">find_proxy</span><span
                                class="method-args">(env=ENV)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a proxy <a href="../URI.html"><code>URI</code></a>. The proxy <a href="../URI.html"><code>URI</code></a> is obtained from environment variables such as http_proxy, ftp_proxy, no_proxy, etc. If there is no proper proxy, nil is returned.</p>

<p>If the optional parameter <code>env</code> is specified, it is used instead of ENV.</p>

<p>Note that capitalized variables (HTTP_PROXY, FTP_PROXY, NO_PROXY, etc.) are examined, too.</p>

<p>But http_proxy and HTTP_PROXY is treated specially under CGI environment. It’s because HTTP_PROXY may be set by Proxy: header. So HTTP_PROXY is not used. http_proxy is not used too if the variable is case insensitive. CGI_HTTP_PROXY can be used instead.</p>

                              <div class="method-source-code" id="find_proxy-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 1499</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">find_proxy</span>(<span class="ruby-identifier">env</span>=<span class="ruby-constant">ENV</span>)
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">BadURIError</span>, <span class="ruby-node">&quot;relative URI: #{self}&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">relative?</span>
  <span class="ruby-identifier">name</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">scheme</span>.<span class="ruby-identifier">downcase</span> <span class="ruby-operator">+</span> <span class="ruby-string">&#39;_proxy&#39;</span>
  <span class="ruby-identifier">proxy_uri</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">name</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;http_proxy&#39;</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">env</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-string">&#39;REQUEST_METHOD&#39;</span>) <span class="ruby-comment"># CGI?</span>
    <span class="ruby-comment"># HTTP_PROXY conflicts with *_proxy for proxy settings and</span>
    <span class="ruby-comment"># HTTP_* for header information in CGI.</span>
    <span class="ruby-comment"># So it should be careful to use it.</span>
    <span class="ruby-identifier">pairs</span> = <span class="ruby-identifier">env</span>.<span class="ruby-identifier">reject</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-regexp">/\Ahttp_proxy\z/i</span> <span class="ruby-operator">!~</span> <span class="ruby-identifier">k</span> }
    <span class="ruby-keyword">case</span> <span class="ruby-identifier">pairs</span>.<span class="ruby-identifier">length</span>
    <span class="ruby-keyword">when</span> <span class="ruby-value">0</span> <span class="ruby-comment"># no proxy setting anyway.</span>
      <span class="ruby-identifier">proxy_uri</span> = <span class="ruby-keyword">nil</span>
    <span class="ruby-keyword">when</span> <span class="ruby-value">1</span>
      <span class="ruby-identifier">k</span>, <span class="ruby-identifier">_</span> = <span class="ruby-identifier">pairs</span>.<span class="ruby-identifier">shift</span>
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">k</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;http_proxy&#39;</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">env</span>[<span class="ruby-identifier">k</span>.<span class="ruby-identifier">upcase</span>] <span class="ruby-operator">==</span> <span class="ruby-keyword">nil</span>
        <span class="ruby-comment"># http_proxy is safe to use because ENV is case sensitive.</span>
        <span class="ruby-identifier">proxy_uri</span> = <span class="ruby-identifier">env</span>[<span class="ruby-identifier">name</span>]
      <span class="ruby-keyword">else</span>
        <span class="ruby-identifier">proxy_uri</span> = <span class="ruby-keyword">nil</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">else</span> <span class="ruby-comment"># http_proxy is safe to use because ENV is case sensitive.</span>
      <span class="ruby-identifier">proxy_uri</span> = <span class="ruby-identifier">env</span>.<span class="ruby-identifier">to_hash</span>[<span class="ruby-identifier">name</span>]
    <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">proxy_uri</span>
      <span class="ruby-comment"># Use CGI_HTTP_PROXY.  cf. libwww-perl.</span>
      <span class="ruby-identifier">proxy_uri</span> = <span class="ruby-identifier">env</span>[<span class="ruby-node">&quot;CGI_#{name.upcase}&quot;</span>]
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">name</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;http_proxy&#39;</span>
    <span class="ruby-keyword">if</span> <span class="ruby-constant">RUBY_ENGINE</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;jruby&#39;</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">p_addr</span> = <span class="ruby-constant">ENV_JAVA</span>[<span class="ruby-string">&#39;http.proxyHost&#39;</span>]
      <span class="ruby-identifier">p_port</span> = <span class="ruby-constant">ENV_JAVA</span>[<span class="ruby-string">&#39;http.proxyPort&#39;</span>]
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">p_user</span> = <span class="ruby-constant">ENV_JAVA</span>[<span class="ruby-string">&#39;http.proxyUser&#39;</span>]
        <span class="ruby-identifier">p_pass</span> = <span class="ruby-constant">ENV_JAVA</span>[<span class="ruby-string">&#39;http.proxyPass&#39;</span>]
        <span class="ruby-identifier">proxy_uri</span> = <span class="ruby-node">&quot;http://#{p_user}:#{p_pass}@#{p_addr}:#{p_port}&quot;</span>
      <span class="ruby-keyword">else</span>
        <span class="ruby-identifier">proxy_uri</span> = <span class="ruby-node">&quot;http://#{p_addr}:#{p_port}&quot;</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-keyword">unless</span> <span class="ruby-identifier">proxy_uri</span> = <span class="ruby-identifier">env</span>[<span class="ruby-identifier">name</span>]
        <span class="ruby-keyword">if</span> <span class="ruby-identifier">proxy_uri</span> = <span class="ruby-identifier">env</span>[<span class="ruby-identifier">name</span>.<span class="ruby-identifier">upcase</span>]
          <span class="ruby-identifier">warn</span> <span class="ruby-string">&#39;The environment variable HTTP_PROXY is discouraged.  Use http_proxy.&#39;</span>, <span class="ruby-value">uplevel:</span> <span class="ruby-value">1</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">proxy_uri</span> = <span class="ruby-identifier">env</span>[<span class="ruby-identifier">name</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">env</span>[<span class="ruby-identifier">name</span>.<span class="ruby-identifier">upcase</span>]
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">proxy_uri</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">proxy_uri</span>.<span class="ruby-identifier">empty?</span>
    <span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">if</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">hostname</span>
    <span class="ruby-keyword">begin</span>
      <span class="ruby-identifier">addr</span> = <span class="ruby-constant">IPSocket</span>.<span class="ruby-identifier">getaddress</span>(<span class="ruby-keyword">self</span>.<span class="ruby-identifier">hostname</span>)
      <span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span> <span class="ruby-keyword">if</span> <span class="ruby-regexp">/\A127\.|\A::1\z/</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">addr</span>
    <span class="ruby-keyword">rescue</span> <span class="ruby-constant">SocketError</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">name</span> = <span class="ruby-string">&#39;no_proxy&#39;</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">no_proxy</span> = <span class="ruby-identifier">env</span>[<span class="ruby-identifier">name</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">env</span>[<span class="ruby-identifier">name</span>.<span class="ruby-identifier">upcase</span>]
    <span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span> <span class="ruby-keyword">unless</span> <span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">Generic</span>.<span class="ruby-identifier">use_proxy?</span>(<span class="ruby-keyword">self</span>.<span class="ruby-identifier">hostname</span>, <span class="ruby-identifier">addr</span>, <span class="ruby-keyword">self</span>.<span class="ruby-identifier">port</span>, <span class="ruby-identifier">no_proxy</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">proxy_uri</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-fragment-3D" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">fragment=</span><span
                                class="method-args">(v)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Checks the fragment <code>v</code> component against the <a href="RFC2396_Parser.html"><code>URI::Parser</code></a> Regexp for :FRAGMENT.</p>

<h2 id="method-i-fragment-3D-label-Args">Args<span><a href="#method-i-fragment-3D-label-Args">&para;</a> <a href="#top">&uarr;</a></span></h2>
<dl class="rdoc-list note-list"><dt><code>v</code>
<dd>
<p>String</p>
</dd></dl>

<h2 id="method-i-fragment-3D-label-Description">Description<span><a href="#method-i-fragment-3D-label-Description">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>Public setter for the fragment component <code>v</code> (with validation).</p>

<h2 id="method-i-fragment-3D-label-Usage">Usage<span><a href="#method-i-fragment-3D-label-Usage">&para;</a> <a href="#top">&uarr;</a></span></h2>

<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;uri&#39;</span>

<span class="ruby-identifier">uri</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-string">&quot;http://my.example.com/?id=25#time=1305212049&quot;</span>)
<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">fragment</span> = <span class="ruby-string">&quot;time=1305212086&quot;</span>
<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">to_s</span>  <span class="ruby-comment">#=&gt; &quot;http://my.example.com/?id=25#time=1305212086&quot;</span>
</pre>

                              <div class="method-source-code" id="fragment-3D-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 929</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">fragment=</span>(<span class="ruby-identifier">v</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-ivar">@fragment</span> = <span class="ruby-keyword">nil</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">v</span>

  <span class="ruby-identifier">x</span> = <span class="ruby-identifier">v</span>.<span class="ruby-identifier">to_str</span>
  <span class="ruby-identifier">v</span> = <span class="ruby-identifier">x</span>.<span class="ruby-identifier">dup</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">x</span>.<span class="ruby-identifier">equal?</span> <span class="ruby-identifier">v</span>
  <span class="ruby-identifier">v</span>.<span class="ruby-identifier">encode!</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">UTF_8</span>) <span class="ruby-keyword">rescue</span> <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">v</span>.<span class="ruby-identifier">delete!</span>(<span class="ruby-string">&quot;\t\r\n&quot;</span>)
  <span class="ruby-identifier">v</span>.<span class="ruby-identifier">force_encoding</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">ASCII_8BIT</span>)
  <span class="ruby-identifier">v</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp">/(?!%\h\h|[!-~])./n</span>){<span class="ruby-string">&#39;%%%02X&#39;</span> <span class="ruby-operator">%</span> <span class="ruby-node">$&amp;</span>.<span class="ruby-identifier">ord</span>}
  <span class="ruby-identifier">v</span>.<span class="ruby-identifier">force_encoding</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">US_ASCII</span>)
  <span class="ruby-ivar">@fragment</span> = <span class="ruby-identifier">v</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-hash" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">hash</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="hash-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 1391</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">hash</span>
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">component_ary</span>.<span class="ruby-identifier">hash</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-hierarchical-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">hierarchical?</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns true if <a href="../URI.html"><code>URI</code></a> is hierarchical.</p>

<h2 id="method-i-hierarchical-3F-label-Description">Description<span><a href="#method-i-hierarchical-3F-label-Description">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p><a href="../URI.html"><code>URI</code></a> has components listed in order of decreasing significance from left to right, see RFC3986 <a href="https://tools.ietf.org/html/rfc3986">tools.ietf.org/html/rfc3986</a> 1.2.3.</p>

<h2 id="method-i-hierarchical-3F-label-Usage">Usage<span><a href="#method-i-hierarchical-3F-label-Usage">&para;</a> <a href="#top">&uarr;</a></span></h2>

<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;uri&#39;</span>

<span class="ruby-identifier">uri</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-string">&quot;http://my.example.com/&quot;</span>)
<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">hierarchical?</span>
<span class="ruby-comment">#=&gt; true</span>
<span class="ruby-identifier">uri</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-string">&quot;mailto:joe@example.com&quot;</span>)
<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">hierarchical?</span>
<span class="ruby-comment">#=&gt; false</span>
</pre>

                              <div class="method-source-code" id="hierarchical-3F-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 961</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">hierarchical?</span>
  <span class="ruby-keyword">if</span> <span class="ruby-ivar">@path</span>
    <span class="ruby-keyword">true</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-keyword">false</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-host-3D" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">host=</span><span
                                class="method-args">(v)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <h2 id="method-i-host-3D-label-Args">Args<span><a href="#method-i-host-3D-label-Args">&para;</a> <a href="#top">&uarr;</a></span></h2>
<dl class="rdoc-list note-list"><dt><code>v</code>
<dd>
<p>String</p>
</dd></dl>

<h2 id="method-i-host-3D-label-Description">Description<span><a href="#method-i-host-3D-label-Description">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>Public setter for the host component <code>v</code> (with validation).</p>

<p>See also <a href="Generic.html#method-i-check_host"><code>URI::Generic.check_host</code></a>.</p>

<h2 id="method-i-host-3D-label-Usage">Usage<span><a href="#method-i-host-3D-label-Usage">&para;</a> <a href="#top">&uarr;</a></span></h2>

<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;uri&#39;</span>

<span class="ruby-identifier">uri</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-string">&quot;http://my.example.com&quot;</span>)
<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">host</span> = <span class="ruby-string">&quot;foo.com&quot;</span>
<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">to_s</span>  <span class="ruby-comment">#=&gt; &quot;http://foo.com&quot;</span>
</pre>

                              <div class="method-source-code" id="host-3D-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 639</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">host=</span>(<span class="ruby-identifier">v</span>)
  <span class="ruby-identifier">check_host</span>(<span class="ruby-identifier">v</span>)
  <span class="ruby-identifier">set_host</span>(<span class="ruby-identifier">v</span>)
  <span class="ruby-identifier">v</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-hostname" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">hostname</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Extract the host part of the <a href="../URI.html"><code>URI</code></a> and unwrap brackets for IPv6 addresses.</p>

<p>This method is the same as <a href="Generic.html#attribute-i-host"><code>URI::Generic#host</code></a> except brackets for IPv6 (and future IP) addresses are removed.</p>

<pre class="ruby"><span class="ruby-identifier">uri</span> = <span class="ruby-constant">URI</span>(<span class="ruby-string">&quot;http://[::1]/bar&quot;</span>)
<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">hostname</span>      <span class="ruby-comment">#=&gt; &quot;::1&quot;</span>
<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">host</span>          <span class="ruby-comment">#=&gt; &quot;[::1]&quot;</span>
</pre>

                              <div class="method-source-code" id="hostname-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 654</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">hostname</span>
  <span class="ruby-identifier">v</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">host</span>
  <span class="ruby-identifier">v</span>&amp;.<span class="ruby-identifier">start_with?</span>(<span class="ruby-string">&#39;[&#39;</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">end_with?</span>(<span class="ruby-string">&#39;]&#39;</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">v</span>[<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">-2</span>] <span class="ruby-operator">:</span> <span class="ruby-identifier">v</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-hostname-3D" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">hostname=</span><span
                                class="method-args">(v)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sets the host part of the <a href="../URI.html"><code>URI</code></a> as the argument with brackets for IPv6 addresses.</p>

<p>This method is the same as <a href="Generic.html#method-i-host-3D"><code>URI::Generic#host=</code></a> except the argument can be a bare IPv6 address.</p>

<pre class="ruby"><span class="ruby-identifier">uri</span> = <span class="ruby-constant">URI</span>(<span class="ruby-string">&quot;http://foo/bar&quot;</span>)
<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">hostname</span> = <span class="ruby-string">&quot;::1&quot;</span>
<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">to_s</span>  <span class="ruby-comment">#=&gt; &quot;http://[::1]/bar&quot;</span>
</pre>

<p>If the argument seems to be an IPv6 address, it is wrapped with brackets.</p>

                              <div class="method-source-code" id="hostname-3D-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 671</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">hostname=</span>(<span class="ruby-identifier">v</span>)
  <span class="ruby-identifier">v</span> = <span class="ruby-node">&quot;[#{v}]&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span>(<span class="ruby-identifier">v</span>&amp;.<span class="ruby-identifier">start_with?</span>(<span class="ruby-string">&#39;[&#39;</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">v</span>&amp;.<span class="ruby-identifier">end_with?</span>(<span class="ruby-string">&#39;]&#39;</span>)) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">v</span>&amp;.<span class="ruby-identifier">index</span>(<span class="ruby-string">&#39;:&#39;</span>)
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">host</span> = <span class="ruby-identifier">v</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-inspect" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">inspect</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="inspect-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 1450</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">inspect</span>
  <span class="ruby-node">&quot;#&lt;#{self.class} #{self}&gt;&quot;</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-merge" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">merge</span><span
                                class="method-args">(oth)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <h2 id="method-i-merge-label-Args">Args<span><a href="#method-i-merge-label-Args">&para;</a> <a href="#top">&uarr;</a></span></h2>
<dl class="rdoc-list note-list"><dt><code>oth</code>
<dd>
<p><a href="../URI.html"><code>URI</code></a> or String</p>
</dd></dl>

<h2 id="method-i-merge-label-Description">Description<span><a href="#method-i-merge-label-Description">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>Merges two URIs.</p>

<h2 id="method-i-merge-label-Usage">Usage<span><a href="#method-i-merge-label-Usage">&para;</a> <a href="#top">&uarr;</a></span></h2>

<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;uri&#39;</span>

<span class="ruby-identifier">uri</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-string">&quot;http://my.example.com&quot;</span>)
<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-string">&quot;/main.rbx?page=1&quot;</span>)
<span class="ruby-comment"># =&gt; &quot;http://my.example.com/main.rbx?page=1&quot;</span>
</pre>

                              <div class="method-source-code" id="merge-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 1109</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">merge</span>(<span class="ruby-identifier">oth</span>)
  <span class="ruby-identifier">rel</span> = <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">__send__</span>(<span class="ruby-value">:convert_to_uri</span>, <span class="ruby-identifier">oth</span>)

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">rel</span>.<span class="ruby-identifier">absolute?</span>
    <span class="ruby-comment">#raise BadURIError, &quot;both URI are absolute&quot; if absolute?</span>
    <span class="ruby-comment"># hmm... should return oth for usability?</span>
    <span class="ruby-keyword">return</span> <span class="ruby-identifier">rel</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">unless</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">absolute?</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">BadURIError</span>, <span class="ruby-string">&quot;both URI are relative&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">base</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">dup</span>

  <span class="ruby-identifier">authority</span> = <span class="ruby-identifier">rel</span>.<span class="ruby-identifier">userinfo</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">rel</span>.<span class="ruby-identifier">host</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">rel</span>.<span class="ruby-identifier">port</span>

  <span class="ruby-comment"># RFC2396, Section 5.2, 2)</span>
  <span class="ruby-keyword">if</span> (<span class="ruby-identifier">rel</span>.<span class="ruby-identifier">path</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">rel</span>.<span class="ruby-identifier">path</span>.<span class="ruby-identifier">empty?</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-identifier">authority</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-identifier">rel</span>.<span class="ruby-identifier">query</span>
    <span class="ruby-identifier">base</span>.<span class="ruby-identifier">fragment</span>=(<span class="ruby-identifier">rel</span>.<span class="ruby-identifier">fragment</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">rel</span>.<span class="ruby-identifier">fragment</span>
    <span class="ruby-keyword">return</span> <span class="ruby-identifier">base</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">base</span>.<span class="ruby-identifier">query</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">base</span>.<span class="ruby-identifier">fragment</span>=(<span class="ruby-keyword">nil</span>)

  <span class="ruby-comment"># RFC2396, Section 5.2, 4)</span>
  <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">authority</span>
    <span class="ruby-identifier">base</span>.<span class="ruby-identifier">set_path</span>(<span class="ruby-identifier">merge_path</span>(<span class="ruby-identifier">base</span>.<span class="ruby-identifier">path</span>, <span class="ruby-identifier">rel</span>.<span class="ruby-identifier">path</span>)) <span class="ruby-keyword">if</span> <span class="ruby-identifier">base</span>.<span class="ruby-identifier">path</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">rel</span>.<span class="ruby-identifier">path</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-comment"># RFC2396, Section 5.2, 4)</span>
    <span class="ruby-identifier">base</span>.<span class="ruby-identifier">set_path</span>(<span class="ruby-identifier">rel</span>.<span class="ruby-identifier">path</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">rel</span>.<span class="ruby-identifier">path</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-comment"># RFC2396, Section 5.2, 7)</span>
  <span class="ruby-identifier">base</span>.<span class="ruby-identifier">set_userinfo</span>(<span class="ruby-identifier">rel</span>.<span class="ruby-identifier">userinfo</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">rel</span>.<span class="ruby-identifier">userinfo</span>
  <span class="ruby-identifier">base</span>.<span class="ruby-identifier">set_host</span>(<span class="ruby-identifier">rel</span>.<span class="ruby-identifier">host</span>)         <span class="ruby-keyword">if</span> <span class="ruby-identifier">rel</span>.<span class="ruby-identifier">host</span>
  <span class="ruby-identifier">base</span>.<span class="ruby-identifier">set_port</span>(<span class="ruby-identifier">rel</span>.<span class="ruby-identifier">port</span>)         <span class="ruby-keyword">if</span> <span class="ruby-identifier">rel</span>.<span class="ruby-identifier">port</span>
  <span class="ruby-identifier">base</span>.<span class="ruby-identifier">query</span> = <span class="ruby-identifier">rel</span>.<span class="ruby-identifier">query</span>       <span class="ruby-keyword">if</span> <span class="ruby-identifier">rel</span>.<span class="ruby-identifier">query</span>
  <span class="ruby-identifier">base</span>.<span class="ruby-identifier">fragment</span>=(<span class="ruby-identifier">rel</span>.<span class="ruby-identifier">fragment</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">rel</span>.<span class="ruby-identifier">fragment</span>

  <span class="ruby-keyword">return</span> <span class="ruby-identifier">base</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="Generic.html#method-i-2B">+</a>
                            </div>

                          </div>

                  <div id="method-i-merge-21" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">merge!</span><span
                                class="method-args">(oth)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <h2 id="method-i-merge-21-label-Args">Args<span><a href="#method-i-merge-21-label-Args">&para;</a> <a href="#top">&uarr;</a></span></h2>
<dl class="rdoc-list note-list"><dt><code>oth</code>
<dd>
<p><a href="../URI.html"><code>URI</code></a> or String</p>
</dd></dl>

<h2 id="method-i-merge-21-label-Description">Description<span><a href="#method-i-merge-21-label-Description">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>Destructive form of <a href="Generic.html#method-i-merge"><code>merge</code></a>.</p>

<h2 id="method-i-merge-21-label-Usage">Usage<span><a href="#method-i-merge-21-label-Usage">&para;</a> <a href="#top">&uarr;</a></span></h2>

<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;uri&#39;</span>

<span class="ruby-identifier">uri</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-string">&quot;http://my.example.com&quot;</span>)
<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-string">&quot;/main.rbx?page=1&quot;</span>)
<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">to_s</span>  <span class="ruby-comment"># =&gt; &quot;http://my.example.com/main.rbx?page=1&quot;</span>
</pre>

                              <div class="method-source-code" id="merge-21-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 1081</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">merge!</span>(<span class="ruby-identifier">oth</span>)
  <span class="ruby-identifier">t</span> = <span class="ruby-identifier">merge</span>(<span class="ruby-identifier">oth</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-keyword">self</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">t</span>
    <span class="ruby-keyword">nil</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">replace!</span>(<span class="ruby-identifier">t</span>)
    <span class="ruby-keyword">self</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-normalize" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">normalize</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns normalized <a href="../URI.html"><code>URI</code></a>.</p>

<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;uri&#39;</span>

<span class="ruby-constant">URI</span>(<span class="ruby-string">&quot;HTTP://my.EXAMPLE.com&quot;</span>).<span class="ruby-identifier">normalize</span>
<span class="ruby-comment">#=&gt; #&lt;URI::HTTP http://my.example.com/&gt;</span>
</pre>

<p>Normalization here means:</p>
<ul><li>
<p>scheme and host are converted to lowercase,</p>
</li><li>
<p>an empty path component is set to “/”.</p>
</li></ul>

                              <div class="method-source-code" id="normalize-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 1319</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">normalize</span>
  <span class="ruby-identifier">uri</span> = <span class="ruby-identifier">dup</span>
  <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">normalize!</span>
  <span class="ruby-identifier">uri</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-normalize-21" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">normalize!</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Destructive version of <a href="Generic.html#method-i-normalize"><code>normalize</code></a>.</p>

                              <div class="method-source-code" id="normalize-21-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 1328</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">normalize!</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">path</span>&amp;.<span class="ruby-identifier">empty?</span>
    <span class="ruby-identifier">set_path</span>(<span class="ruby-string">&#39;/&#39;</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">scheme</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">scheme</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">scheme</span>.<span class="ruby-identifier">downcase</span>
    <span class="ruby-identifier">set_scheme</span>(<span class="ruby-keyword">self</span>.<span class="ruby-identifier">scheme</span>.<span class="ruby-identifier">downcase</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">host</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">host</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">host</span>.<span class="ruby-identifier">downcase</span>
    <span class="ruby-identifier">set_host</span>(<span class="ruby-keyword">self</span>.<span class="ruby-identifier">host</span>.<span class="ruby-identifier">downcase</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-opaque-3D" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">opaque=</span><span
                                class="method-args">(v)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <h2 id="method-i-opaque-3D-label-Args">Args<span><a href="#method-i-opaque-3D-label-Args">&para;</a> <a href="#top">&uarr;</a></span></h2>
<dl class="rdoc-list note-list"><dt><code>v</code>
<dd>
<p>String</p>
</dd></dl>

<h2 id="method-i-opaque-3D-label-Description">Description<span><a href="#method-i-opaque-3D-label-Description">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>Public setter for the opaque component <code>v</code> (with validation).</p>

<p>See also <a href="Generic.html#method-i-check_opaque"><code>URI::Generic.check_opaque</code></a>.</p>

                              <div class="method-source-code" id="opaque-3D-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 901</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">opaque=</span>(<span class="ruby-identifier">v</span>)
  <span class="ruby-identifier">check_opaque</span>(<span class="ruby-identifier">v</span>)
  <span class="ruby-identifier">set_opaque</span>(<span class="ruby-identifier">v</span>)
  <span class="ruby-identifier">v</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-parser" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">parser</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the parser to be used.</p>

<p>Unless a <a href="RFC2396_Parser.html"><code>URI::Parser</code></a> is defined, DEFAULT_PARSER is used.</p>

                              <div class="method-source-code" id="parser-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 289</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">parser</span>
  <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-keyword">defined?</span>(<span class="ruby-ivar">@parser</span>) <span class="ruby-operator">||</span> <span class="ruby-operator">!</span><span class="ruby-ivar">@parser</span>
    <span class="ruby-constant">DEFAULT_PARSER</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-ivar">@parser</span> <span class="ruby-operator">||</span> <span class="ruby-constant">DEFAULT_PARSER</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-password" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">password</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the password component (without <a href="../URI.html"><code>URI</code></a> decoding).</p>

                              <div class="method-source-code" id="password-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 573</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">password</span>
  <span class="ruby-ivar">@password</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-password-3D" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">password=</span><span
                                class="method-args">(password)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <h2 id="method-i-password-3D-label-Args">Args<span><a href="#method-i-password-3D-label-Args">&para;</a> <a href="#top">&uarr;</a></span></h2>
<dl class="rdoc-list note-list"><dt><code>v</code>
<dd>
<p>String</p>
</dd></dl>

<h2 id="method-i-password-3D-label-Description">Description<span><a href="#method-i-password-3D-label-Description">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>Public setter for the <code>password</code> component (with validation).</p>

<p>See also <a href="Generic.html#method-i-check_password"><code>URI::Generic.check_password</code></a>.</p>

<h2 id="method-i-password-3D-label-Usage">Usage<span><a href="#method-i-password-3D-label-Usage">&para;</a> <a href="#top">&uarr;</a></span></h2>

<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;uri&#39;</span>

<span class="ruby-identifier">uri</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-string">&quot;http://john:S3nsit1ve@my.example.com&quot;</span>)
<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">password</span> = <span class="ruby-string">&quot;V3ry_S3nsit1ve&quot;</span>
<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">to_s</span>  <span class="ruby-comment">#=&gt; &quot;http://john:V3ry_S3nsit1ve@my.example.com&quot;</span>
</pre>

                              <div class="method-source-code" id="password-3D-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 498</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">password=</span>(<span class="ruby-identifier">password</span>)
  <span class="ruby-identifier">check_password</span>(<span class="ruby-identifier">password</span>)
  <span class="ruby-identifier">set_password</span>(<span class="ruby-identifier">password</span>)
  <span class="ruby-comment"># returns password</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-path-3D" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">path=</span><span
                                class="method-args">(v)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <h2 id="method-i-path-3D-label-Args">Args<span><a href="#method-i-path-3D-label-Args">&para;</a> <a href="#top">&uarr;</a></span></h2>
<dl class="rdoc-list note-list"><dt><code>v</code>
<dd>
<p>String</p>
</dd></dl>

<h2 id="method-i-path-3D-label-Description">Description<span><a href="#method-i-path-3D-label-Description">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>Public setter for the path component <code>v</code> (with validation).</p>

<p>See also <a href="Generic.html#method-i-check_path"><code>URI::Generic.check_path</code></a>.</p>

<h2 id="method-i-path-3D-label-Usage">Usage<span><a href="#method-i-path-3D-label-Usage">&para;</a> <a href="#top">&uarr;</a></span></h2>

<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;uri&#39;</span>

<span class="ruby-identifier">uri</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-string">&quot;http://my.example.com/pub/files&quot;</span>)
<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">path</span> = <span class="ruby-string">&quot;/faq/&quot;</span>
<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">to_s</span>  <span class="ruby-comment">#=&gt; &quot;http://my.example.com/faq/&quot;</span>
</pre>

                              <div class="method-source-code" id="path-3D-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 815</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">path=</span>(<span class="ruby-identifier">v</span>)
  <span class="ruby-identifier">check_path</span>(<span class="ruby-identifier">v</span>)
  <span class="ruby-identifier">set_path</span>(<span class="ruby-identifier">v</span>)
  <span class="ruby-identifier">v</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-port-3D" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">port=</span><span
                                class="method-args">(v)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <h2 id="method-i-port-3D-label-Args">Args<span><a href="#method-i-port-3D-label-Args">&para;</a> <a href="#top">&uarr;</a></span></h2>
<dl class="rdoc-list note-list"><dt><code>v</code>
<dd>
<p>String</p>
</dd></dl>

<h2 id="method-i-port-3D-label-Description">Description<span><a href="#method-i-port-3D-label-Description">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>Public setter for the port component <code>v</code> (with validation).</p>

<p>See also <a href="Generic.html#method-i-check_port"><code>URI::Generic.check_port</code></a>.</p>

<h2 id="method-i-port-3D-label-Usage">Usage<span><a href="#method-i-port-3D-label-Usage">&para;</a> <a href="#top">&uarr;</a></span></h2>

<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;uri&#39;</span>

<span class="ruby-identifier">uri</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-string">&quot;http://my.example.com&quot;</span>)
<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">port</span> = <span class="ruby-value">8080</span>
<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">to_s</span>  <span class="ruby-comment">#=&gt; &quot;http://my.example.com:8080&quot;</span>
</pre>

                              <div class="method-source-code" id="port-3D-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 729</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">port=</span>(<span class="ruby-identifier">v</span>)
  <span class="ruby-identifier">check_port</span>(<span class="ruby-identifier">v</span>)
  <span class="ruby-identifier">set_port</span>(<span class="ruby-identifier">v</span>)
  <span class="ruby-identifier">port</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-query-3D" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">query=</span><span
                                class="method-args">(v)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <h2 id="method-i-query-3D-label-Args">Args<span><a href="#method-i-query-3D-label-Args">&para;</a> <a href="#top">&uarr;</a></span></h2>
<dl class="rdoc-list note-list"><dt><code>v</code>
<dd>
<p>String</p>
</dd></dl>

<h2 id="method-i-query-3D-label-Description">Description<span><a href="#method-i-query-3D-label-Description">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>Public setter for the query component <code>v</code>.</p>

<h2 id="method-i-query-3D-label-Usage">Usage<span><a href="#method-i-query-3D-label-Usage">&para;</a> <a href="#top">&uarr;</a></span></h2>

<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;uri&#39;</span>

<span class="ruby-identifier">uri</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-string">&quot;http://my.example.com/?id=25&quot;</span>)
<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">query</span> = <span class="ruby-string">&quot;id=1&quot;</span>
<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">to_s</span>  <span class="ruby-comment">#=&gt; &quot;http://my.example.com/?id=1&quot;</span>
</pre>

                              <div class="method-source-code" id="query-3D-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 839</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">query=</span>(<span class="ruby-identifier">v</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-ivar">@query</span> = <span class="ruby-keyword">nil</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">v</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidURIError</span>, <span class="ruby-string">&quot;query conflicts with opaque&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@opaque</span>

  <span class="ruby-identifier">x</span> = <span class="ruby-identifier">v</span>.<span class="ruby-identifier">to_str</span>
  <span class="ruby-identifier">v</span> = <span class="ruby-identifier">x</span>.<span class="ruby-identifier">dup</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">x</span>.<span class="ruby-identifier">equal?</span> <span class="ruby-identifier">v</span>
  <span class="ruby-identifier">v</span>.<span class="ruby-identifier">encode!</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">UTF_8</span>) <span class="ruby-keyword">rescue</span> <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">v</span>.<span class="ruby-identifier">delete!</span>(<span class="ruby-string">&quot;\t\r\n&quot;</span>)
  <span class="ruby-identifier">v</span>.<span class="ruby-identifier">force_encoding</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">ASCII_8BIT</span>)
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidURIError</span>, <span class="ruby-node">&quot;invalid percent escape: #{$1}&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-regexp">/(%\H\H)/n</span>.<span class="ruby-identifier">match</span>(<span class="ruby-identifier">v</span>)
  <span class="ruby-identifier">v</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp">/(?!%\h\h|[!$-&amp;(-;=?-_a-~])./n</span>.<span class="ruby-identifier">freeze</span>){<span class="ruby-string">&#39;%%%02X&#39;</span> <span class="ruby-operator">%</span> <span class="ruby-node">$&amp;</span>.<span class="ruby-identifier">ord</span>}
  <span class="ruby-identifier">v</span>.<span class="ruby-identifier">force_encoding</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">US_ASCII</span>)
  <span class="ruby-ivar">@query</span> = <span class="ruby-identifier">v</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-registry-3D" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">registry=</span><span
                                class="method-args">(v)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="registry-3D-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 745</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">registry=</span>(<span class="ruby-identifier">v</span>)
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidURIError</span>, <span class="ruby-string">&quot;can not set registry&quot;</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-relative-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">relative?</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns true if <a href="../URI.html"><code>URI</code></a> does not have a scheme (e.g. http:// or https://) specified.</p>

                              <div class="method-source-code" id="relative-3F-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 984</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">relative?</span>
  <span class="ruby-operator">!</span><span class="ruby-identifier">absolute?</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-route_from" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">route_from</span><span
                                class="method-args">(oth)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <h2 id="method-i-route_from-label-Args">Args<span><a href="#method-i-route_from-label-Args">&para;</a> <a href="#top">&uarr;</a></span></h2>
<dl class="rdoc-list note-list"><dt><code>oth</code>
<dd>
<p><a href="../URI.html"><code>URI</code></a> or String</p>
</dd></dl>

<h2 id="method-i-route_from-label-Description">Description<span><a href="#method-i-route_from-label-Description">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>Calculates relative path from oth to self.</p>

<h2 id="method-i-route_from-label-Usage">Usage<span><a href="#method-i-route_from-label-Usage">&para;</a> <a href="#top">&uarr;</a></span></h2>

<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;uri&#39;</span>

<span class="ruby-identifier">uri</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-string">&#39;http://my.example.com/main.rbx?page=1&#39;</span>)
<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">route_from</span>(<span class="ruby-string">&#39;http://my.example.com&#39;</span>)
<span class="ruby-comment">#=&gt; #&lt;URI::Generic /main.rbx?page=1&gt;</span>
</pre>

                              <div class="method-source-code" id="route_from-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 1262</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">route_from</span>(<span class="ruby-identifier">oth</span>)
  <span class="ruby-comment"># you can modify `rel&#39;, but can not `oth&#39;.</span>
  <span class="ruby-keyword">begin</span>
    <span class="ruby-identifier">oth</span>, <span class="ruby-identifier">rel</span> = <span class="ruby-identifier">route_from0</span>(<span class="ruby-identifier">oth</span>)
  <span class="ruby-keyword">rescue</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-identifier">$!</span>.<span class="ruby-identifier">class</span>, <span class="ruby-identifier">$!</span>.<span class="ruby-identifier">message</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">oth</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">rel</span>
    <span class="ruby-keyword">return</span> <span class="ruby-identifier">rel</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">rel</span>.<span class="ruby-identifier">set_path</span>(<span class="ruby-identifier">route_from_path</span>(<span class="ruby-identifier">oth</span>.<span class="ruby-identifier">path</span>, <span class="ruby-keyword">self</span>.<span class="ruby-identifier">path</span>))
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">rel</span>.<span class="ruby-identifier">path</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;./&#39;</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">query</span>
    <span class="ruby-comment"># &quot;./?foo&quot; -&gt; &quot;?foo&quot;</span>
    <span class="ruby-identifier">rel</span>.<span class="ruby-identifier">set_path</span>(<span class="ruby-string">&#39;&#39;</span>)
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">return</span> <span class="ruby-identifier">rel</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="Generic.html#method-i-2D">-</a>
                            </div>

                          </div>

                  <div id="method-i-route_to" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">route_to</span><span
                                class="method-args">(oth)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <h2 id="method-i-route_to-label-Args">Args<span><a href="#method-i-route_to-label-Args">&para;</a> <a href="#top">&uarr;</a></span></h2>
<dl class="rdoc-list note-list"><dt><code>oth</code>
<dd>
<p><a href="../URI.html"><code>URI</code></a> or String</p>
</dd></dl>

<h2 id="method-i-route_to-label-Description">Description<span><a href="#method-i-route_to-label-Description">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>Calculates relative path to oth from self.</p>

<h2 id="method-i-route_to-label-Usage">Usage<span><a href="#method-i-route_to-label-Usage">&para;</a> <a href="#top">&uarr;</a></span></h2>

<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;uri&#39;</span>

<span class="ruby-identifier">uri</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-string">&#39;http://my.example.com&#39;</span>)
<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">route_to</span>(<span class="ruby-string">&#39;http://my.example.com/main.rbx?page=1&#39;</span>)
<span class="ruby-comment">#=&gt; #&lt;URI::Generic /main.rbx?page=1&gt;</span>
</pre>

                              <div class="method-source-code" id="route_to-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 1302</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">route_to</span>(<span class="ruby-identifier">oth</span>)
  <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">__send__</span>(<span class="ruby-value">:convert_to_uri</span>, <span class="ruby-identifier">oth</span>).<span class="ruby-identifier">route_from</span>(<span class="ruby-keyword">self</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-scheme-3D" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">scheme=</span><span
                                class="method-args">(v)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <h2 id="method-i-scheme-3D-label-Args">Args<span><a href="#method-i-scheme-3D-label-Args">&para;</a> <a href="#top">&uarr;</a></span></h2>
<dl class="rdoc-list note-list"><dt><code>v</code>
<dd>
<p>String</p>
</dd></dl>

<h2 id="method-i-scheme-3D-label-Description">Description<span><a href="#method-i-scheme-3D-label-Description">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>Public setter for the scheme component <code>v</code> (with validation).</p>

<p>See also <a href="Generic.html#method-i-check_scheme"><code>URI::Generic.check_scheme</code></a>.</p>

<h2 id="method-i-scheme-3D-label-Usage">Usage<span><a href="#method-i-scheme-3D-label-Usage">&para;</a> <a href="#top">&uarr;</a></span></h2>

<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;uri&#39;</span>

<span class="ruby-identifier">uri</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-string">&quot;http://my.example.com&quot;</span>)
<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">scheme</span> = <span class="ruby-string">&quot;https&quot;</span>
<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">to_s</span>  <span class="ruby-comment">#=&gt; &quot;https://my.example.com&quot;</span>
</pre>

                              <div class="method-source-code" id="scheme-3D-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 360</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">scheme=</span>(<span class="ruby-identifier">v</span>)
  <span class="ruby-identifier">check_scheme</span>(<span class="ruby-identifier">v</span>)
  <span class="ruby-identifier">set_scheme</span>(<span class="ruby-identifier">v</span>)
  <span class="ruby-identifier">v</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-select" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">select</span><span
                                class="method-args">(*components)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <h2 id="method-i-select-label-Args">Args<span><a href="#method-i-select-label-Args">&para;</a> <a href="#top">&uarr;</a></span></h2>
<dl class="rdoc-list note-list"><dt><code>components</code>
<dd>
<p>Multiple Symbol arguments defined in <a href="HTTP.html"><code>URI::HTTP</code></a>.</p>
</dd></dl>

<h2 id="method-i-select-label-Description">Description<span><a href="#method-i-select-label-Description">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>Selects specified components from <a href="../URI.html"><code>URI</code></a>.</p>

<h2 id="method-i-select-label-Usage">Usage<span><a href="#method-i-select-label-Usage">&para;</a> <a href="#top">&uarr;</a></span></h2>

<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;uri&#39;</span>

<span class="ruby-identifier">uri</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-string">&#39;http://myuser:mypass@my.example.com/test.rbx&#39;</span>)
<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">select</span>(<span class="ruby-value">:userinfo</span>, <span class="ruby-value">:host</span>, <span class="ruby-value">:path</span>)
<span class="ruby-comment"># =&gt; [&quot;myuser:mypass&quot;, &quot;my.example.com&quot;, &quot;/test.rbx&quot;]</span>
</pre>

                              <div class="method-source-code" id="select-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 1439</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">select</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">components</span>)
  <span class="ruby-identifier">components</span>.<span class="ruby-identifier">collect</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">component</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">c</span>)
      <span class="ruby-keyword">self</span>.<span class="ruby-identifier">__send__</span>(<span class="ruby-identifier">c</span>)
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>,
        <span class="ruby-node">&quot;expected of components of #{self.class} (#{self.class.component.join(&#39;, &#39;)})&quot;</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-to_s" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">to_s</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Constructs String from <a href="../URI.html"><code>URI</code></a>.</p>

                              <div class="method-source-code" id="to_s-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 1343</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">to_s</span>
  <span class="ruby-identifier">str</span> = <span class="ruby-string">&#39;&#39;</span>.<span class="ruby-identifier">dup</span>
  <span class="ruby-keyword">if</span> <span class="ruby-ivar">@scheme</span>
    <span class="ruby-identifier">str</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-ivar">@scheme</span>
    <span class="ruby-identifier">str</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&#39;:&#39;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">if</span> <span class="ruby-ivar">@opaque</span>
    <span class="ruby-identifier">str</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-ivar">@opaque</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-keyword">if</span> <span class="ruby-ivar">@host</span> <span class="ruby-operator">||</span> <span class="ruby-node">%w[file postgres]</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-ivar">@scheme</span>)
      <span class="ruby-identifier">str</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&#39;//&#39;</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">if</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">userinfo</span>
      <span class="ruby-identifier">str</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">userinfo</span>
      <span class="ruby-identifier">str</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&#39;@&#39;</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">if</span> <span class="ruby-ivar">@host</span>
      <span class="ruby-identifier">str</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-ivar">@host</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">if</span> <span class="ruby-ivar">@port</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-ivar">@port</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">default_port</span>
      <span class="ruby-identifier">str</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&#39;:&#39;</span>
      <span class="ruby-identifier">str</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-ivar">@port</span>.<span class="ruby-identifier">to_s</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">str</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-ivar">@path</span>
    <span class="ruby-keyword">if</span> <span class="ruby-ivar">@query</span>
      <span class="ruby-identifier">str</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&#39;?&#39;</span>
      <span class="ruby-identifier">str</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-ivar">@query</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">if</span> <span class="ruby-ivar">@fragment</span>
    <span class="ruby-identifier">str</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&#39;#&#39;</span>
    <span class="ruby-identifier">str</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-ivar">@fragment</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">str</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-user" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">user</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the user component (without <a href="../URI.html"><code>URI</code></a> decoding).</p>

                              <div class="method-source-code" id="user-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 568</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">user</span>
  <span class="ruby-ivar">@user</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-user-3D" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">user=</span><span
                                class="method-args">(user)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <h2 id="method-i-user-3D-label-Args">Args<span><a href="#method-i-user-3D-label-Args">&para;</a> <a href="#top">&uarr;</a></span></h2>
<dl class="rdoc-list note-list"><dt><code>v</code>
<dd>
<p>String</p>
</dd></dl>

<h2 id="method-i-user-3D-label-Description">Description<span><a href="#method-i-user-3D-label-Description">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>Public setter for the <code>user</code> component (with validation).</p>

<p>See also <a href="Generic.html#method-i-check_user"><code>URI::Generic.check_user</code></a>.</p>

<h2 id="method-i-user-3D-label-Usage">Usage<span><a href="#method-i-user-3D-label-Usage">&para;</a> <a href="#top">&uarr;</a></span></h2>

<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;uri&#39;</span>

<span class="ruby-identifier">uri</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-string">&quot;http://john:S3nsit1ve@my.example.com&quot;</span>)
<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">user</span> = <span class="ruby-string">&quot;sam&quot;</span>
<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">to_s</span>  <span class="ruby-comment">#=&gt; &quot;http://sam:V3ry_S3nsit1ve@my.example.com&quot;</span>
</pre>

                              <div class="method-source-code" id="user-3D-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 471</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">user=</span>(<span class="ruby-identifier">user</span>)
  <span class="ruby-identifier">check_user</span>(<span class="ruby-identifier">user</span>)
  <span class="ruby-identifier">set_user</span>(<span class="ruby-identifier">user</span>)
  <span class="ruby-comment"># returns user</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-userinfo" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">userinfo</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the userinfo, either as ‘user’ or ‘user:password’.</p>

                              <div class="method-source-code" id="userinfo-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 557</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">userinfo</span>
  <span class="ruby-keyword">if</span> <span class="ruby-ivar">@user</span>.<span class="ruby-identifier">nil?</span>
    <span class="ruby-keyword">nil</span>
  <span class="ruby-keyword">elsif</span> <span class="ruby-ivar">@password</span>.<span class="ruby-identifier">nil?</span>
    <span class="ruby-ivar">@user</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-ivar">@user</span> <span class="ruby-operator">+</span> <span class="ruby-string">&#39;:&#39;</span> <span class="ruby-operator">+</span> <span class="ruby-ivar">@password</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-userinfo-3D" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">userinfo=</span><span
                                class="method-args">(userinfo)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Sets userinfo, argument is string like ‘name:pass’.</p>

                              <div class="method-source-code" id="userinfo-3D-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 441</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">userinfo=</span>(<span class="ruby-identifier">userinfo</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">userinfo</span>.<span class="ruby-identifier">nil?</span>
    <span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">check_userinfo</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">userinfo</span>)
  <span class="ruby-identifier">set_userinfo</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">userinfo</span>)
  <span class="ruby-comment"># returns userinfo</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="protected-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Protected Instance Methods</h3>
                </header>

                  <div id="method-i-component_ary" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">component_ary</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns an Array of the components defined from the <a href="Generic.html#COMPONENT"><code>COMPONENT</code></a> Array.</p>

                              <div class="method-source-code" id="component_ary-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 1415</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">component_ary</span>
  <span class="ruby-identifier">component</span>.<span class="ruby-identifier">collect</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">__send__</span>(<span class="ruby-identifier">x</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-set_host" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">set_host</span><span
                                class="method-args">(v)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Protected setter for the host component <code>v</code>.</p>

<p>See also <a href="Generic.html#method-i-host-3D"><code>URI::Generic.host=</code></a>.</p>

                              <div class="method-source-code" id="set_host-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 613</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">set_host</span>(<span class="ruby-identifier">v</span>)
  <span class="ruby-ivar">@host</span> = <span class="ruby-identifier">v</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-set_opaque" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">set_opaque</span><span
                                class="method-args">(v)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Protected setter for the opaque component <code>v</code>.</p>

<p>See also <a href="Generic.html#method-i-opaque-3D"><code>URI::Generic.opaque=</code></a>.</p>

                              <div class="method-source-code" id="set_opaque-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 883</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">set_opaque</span>(<span class="ruby-identifier">v</span>)
  <span class="ruby-ivar">@opaque</span> = <span class="ruby-identifier">v</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-set_password" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">set_password</span><span
                                class="method-args">(v)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Protected setter for the password component <code>v</code>.</p>

<p>See also <a href="Generic.html#method-i-password-3D"><code>URI::Generic.password=</code></a>.</p>

                              <div class="method-source-code" id="set_password-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 534</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">set_password</span>(<span class="ruby-identifier">v</span>)
  <span class="ruby-ivar">@password</span> = <span class="ruby-identifier">v</span>
  <span class="ruby-comment"># returns v</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-set_path" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">set_path</span><span
                                class="method-args">(v)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Protected setter for the path component <code>v</code>.</p>

<p>See also <a href="Generic.html#method-i-path-3D"><code>URI::Generic.path=</code></a>.</p>

                              <div class="method-source-code" id="set_path-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 789</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">set_path</span>(<span class="ruby-identifier">v</span>)
  <span class="ruby-ivar">@path</span> = <span class="ruby-identifier">v</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-set_port" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">set_port</span><span
                                class="method-args">(v)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Protected setter for the port component <code>v</code>.</p>

<p>See also <a href="Generic.html#method-i-port-3D"><code>URI::Generic.port=</code></a>.</p>

                              <div class="method-source-code" id="set_port-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 702</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">set_port</span>(<span class="ruby-identifier">v</span>)
  <span class="ruby-identifier">v</span> = <span class="ruby-identifier">v</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-operator">?</span> <span class="ruby-keyword">nil</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-keyword">unless</span> <span class="ruby-operator">!</span><span class="ruby-identifier">v</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Integer</span>)
  <span class="ruby-ivar">@port</span> = <span class="ruby-identifier">v</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-set_scheme" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">set_scheme</span><span
                                class="method-args">(v)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Protected setter for the scheme component <code>v</code>.</p>

<p>See also <a href="Generic.html#method-i-scheme-3D"><code>URI::Generic.scheme=</code></a>.</p>

                              <div class="method-source-code" id="set_scheme-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 334</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">set_scheme</span>(<span class="ruby-identifier">v</span>)
  <span class="ruby-ivar">@scheme</span> = <span class="ruby-identifier">v</span>&amp;.<span class="ruby-identifier">downcase</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-set_user" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">set_user</span><span
                                class="method-args">(v)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Protected setter for the user component <code>v</code>.</p>

<p>See also <a href="Generic.html#method-i-user-3D"><code>URI::Generic.user=</code></a>.</p>

                              <div class="method-source-code" id="set_user-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 524</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">set_user</span>(<span class="ruby-identifier">v</span>)
  <span class="ruby-identifier">set_userinfo</span>(<span class="ruby-identifier">v</span>, <span class="ruby-ivar">@password</span>)
  <span class="ruby-identifier">v</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-set_userinfo" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">set_userinfo</span><span
                                class="method-args">(user, password = nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Protected setter for the <code>user</code> component, and <code>password</code> if available (with validation).</p>

<p>See also <a href="Generic.html#method-i-userinfo-3D"><code>URI::Generic.userinfo=</code></a>.</p>

                              <div class="method-source-code" id="set_userinfo-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 509</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">set_userinfo</span>(<span class="ruby-identifier">user</span>, <span class="ruby-identifier">password</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">password</span>
    <span class="ruby-identifier">user</span>, <span class="ruby-identifier">password</span> = <span class="ruby-identifier">split_userinfo</span>(<span class="ruby-identifier">user</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-ivar">@user</span>     = <span class="ruby-identifier">user</span>
  <span class="ruby-ivar">@password</span> = <span class="ruby-identifier">password</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">password</span>

  [<span class="ruby-ivar">@user</span>, <span class="ruby-ivar">@password</span>]
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="private-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Private Instance Methods</h3>
                </header>

                  <div id="method-i-check_host" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">check_host</span><span
                                class="method-args">(v)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Checks the host <code>v</code> component for RFC2396 compliance and against the <a href="RFC2396_Parser.html"><code>URI::Parser</code></a> Regexp for :HOST.</p>

<p>Can not have a registry or opaque component defined, with a host component defined.</p>

                              <div class="method-source-code" id="check_host-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 594</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">check_host</span>(<span class="ruby-identifier">v</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">v</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">v</span>

  <span class="ruby-keyword">if</span> <span class="ruby-ivar">@opaque</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidURIError</span>,
      <span class="ruby-string">&quot;can not set host with registry or opaque&quot;</span>
  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">regexp</span>[<span class="ruby-value">:HOST</span>] <span class="ruby-operator">!~</span> <span class="ruby-identifier">v</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidComponentError</span>,
      <span class="ruby-node">&quot;bad component(expected host component): #{v}&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">return</span> <span class="ruby-keyword">true</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-check_opaque" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">check_opaque</span><span
                                class="method-args">(v)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Checks the opaque <code>v</code> component for RFC2396 compliance and against the <a href="RFC2396_Parser.html"><code>URI::Parser</code></a> Regexp for :OPAQUE.</p>

<p>Can not have a host, port, user, or path component defined, with an opaque component defined.</p>

                              <div class="method-source-code" id="check_opaque-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 861</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">check_opaque</span>(<span class="ruby-identifier">v</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">v</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">v</span>

  <span class="ruby-comment"># raise if both hier and opaque are not nil, because:</span>
  <span class="ruby-comment"># absoluteURI   = scheme &quot;:&quot; ( hier_part | opaque_part )</span>
  <span class="ruby-comment"># hier_part     = ( net_path | abs_path ) [ &quot;?&quot; query ]</span>
  <span class="ruby-keyword">if</span> <span class="ruby-ivar">@host</span> <span class="ruby-operator">||</span> <span class="ruby-ivar">@port</span> <span class="ruby-operator">||</span> <span class="ruby-ivar">@user</span> <span class="ruby-operator">||</span> <span class="ruby-ivar">@path</span>  <span class="ruby-comment"># userinfo = @user + &#39;:&#39; + @password</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidURIError</span>,
      <span class="ruby-string">&quot;can not set opaque with host, port, userinfo or path&quot;</span>
  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">v</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">regexp</span>[<span class="ruby-value">:OPAQUE</span>] <span class="ruby-operator">!~</span> <span class="ruby-identifier">v</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidComponentError</span>,
      <span class="ruby-node">&quot;bad component(expected opaque component): #{v}&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">return</span> <span class="ruby-keyword">true</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-check_password" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">check_password</span><span
                                class="method-args">(v, user = @user)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Checks the password <code>v</code> component for RFC2396 compliance and against the <a href="RFC2396_Parser.html"><code>URI::Parser</code></a> Regexp for :USERINFO.</p>

<p>Can not have a registry or opaque component defined, with a user component defined.</p>

                              <div class="method-source-code" id="check_password-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 417</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">check_password</span>(<span class="ruby-identifier">v</span>, <span class="ruby-identifier">user</span> = <span class="ruby-ivar">@user</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-ivar">@opaque</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidURIError</span>,
      <span class="ruby-string">&quot;can not set password with opaque&quot;</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">v</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">v</span>

  <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">user</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidURIError</span>,
      <span class="ruby-string">&quot;password component depends user component&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">regexp</span>[<span class="ruby-value">:USERINFO</span>] <span class="ruby-operator">!~</span> <span class="ruby-identifier">v</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidComponentError</span>,
      <span class="ruby-string">&quot;bad password component&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">return</span> <span class="ruby-keyword">true</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-check_path" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">check_path</span><span
                                class="method-args">(v)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Checks the path <code>v</code> component for RFC2396 compliance and against the <a href="RFC2396_Parser.html"><code>URI::Parser</code></a> Regexp for :ABS_PATH and :REL_PATH.</p>

<p>Can not have a opaque component defined, with a path component defined.</p>

                              <div class="method-source-code" id="check_path-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 757</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">check_path</span>(<span class="ruby-identifier">v</span>)
  <span class="ruby-comment"># raise if both hier and opaque are not nil, because:</span>
  <span class="ruby-comment"># absoluteURI   = scheme &quot;:&quot; ( hier_part | opaque_part )</span>
  <span class="ruby-comment"># hier_part     = ( net_path | abs_path ) [ &quot;?&quot; query ]</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">v</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-ivar">@opaque</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidURIError</span>,
      <span class="ruby-string">&quot;path conflicts with opaque&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-comment"># If scheme is ftp, path may be relative.</span>
  <span class="ruby-comment"># See RFC 1738 section 3.2.2, and RFC 2396.</span>
  <span class="ruby-keyword">if</span> <span class="ruby-ivar">@scheme</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-ivar">@scheme</span> <span class="ruby-operator">!=</span> <span class="ruby-string">&quot;ftp&quot;</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">v</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">v</span> <span class="ruby-operator">!=</span> <span class="ruby-string">&#39;&#39;</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">regexp</span>[<span class="ruby-value">:ABS_PATH</span>] <span class="ruby-operator">!~</span> <span class="ruby-identifier">v</span>
      <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidComponentError</span>,
        <span class="ruby-node">&quot;bad component(expected absolute path component): #{v}&quot;</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">v</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">v</span> <span class="ruby-operator">!=</span> <span class="ruby-string">&#39;&#39;</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">regexp</span>[<span class="ruby-value">:ABS_PATH</span>] <span class="ruby-operator">!~</span> <span class="ruby-identifier">v</span> <span class="ruby-operator">&amp;&amp;</span>
       <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">regexp</span>[<span class="ruby-value">:REL_PATH</span>] <span class="ruby-operator">!~</span> <span class="ruby-identifier">v</span>
      <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidComponentError</span>,
        <span class="ruby-node">&quot;bad component(expected relative path component): #{v}&quot;</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">return</span> <span class="ruby-keyword">true</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-check_port" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">check_port</span><span
                                class="method-args">(v)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Checks the port <code>v</code> component for RFC2396 compliance and against the <a href="RFC2396_Parser.html"><code>URI::Parser</code></a> Regexp for :PORT.</p>

<p>Can not have a registry or opaque component defined, with a port component defined.</p>

                              <div class="method-source-code" id="check_port-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 683</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">check_port</span>(<span class="ruby-identifier">v</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">v</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">v</span>

  <span class="ruby-keyword">if</span> <span class="ruby-ivar">@opaque</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidURIError</span>,
      <span class="ruby-string">&quot;can not set port with registry or opaque&quot;</span>
  <span class="ruby-keyword">elsif</span> <span class="ruby-operator">!</span><span class="ruby-identifier">v</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Integer</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">regexp</span>[<span class="ruby-value">:PORT</span>] <span class="ruby-operator">!~</span> <span class="ruby-identifier">v</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidComponentError</span>,
      <span class="ruby-node">&quot;bad component(expected port component): #{v.inspect}&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">return</span> <span class="ruby-keyword">true</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-check_scheme" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">check_scheme</span><span
                                class="method-args">(v)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Checks the scheme <code>v</code> component against the <a href="RFC2396_Parser.html"><code>URI::Parser</code></a> Regexp for :SCHEME.</p>

                              <div class="method-source-code" id="check_scheme-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 320</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">check_scheme</span>(<span class="ruby-identifier">v</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">v</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">regexp</span>[<span class="ruby-value">:SCHEME</span>] <span class="ruby-operator">!~</span> <span class="ruby-identifier">v</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidComponentError</span>,
      <span class="ruby-node">&quot;bad component(expected scheme component): #{v}&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">return</span> <span class="ruby-keyword">true</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-check_user" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">check_user</span><span
                                class="method-args">(v)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Checks the user <code>v</code> component for RFC2396 compliance and against the <a href="RFC2396_Parser.html"><code>URI::Parser</code></a> Regexp for :USERINFO.</p>

<p>Can not have a registry or opaque component defined, with a user component defined.</p>

                              <div class="method-source-code" id="check_user-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 393</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">check_user</span>(<span class="ruby-identifier">v</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-ivar">@opaque</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidURIError</span>,
      <span class="ruby-string">&quot;can not set user with opaque&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">return</span> <span class="ruby-identifier">v</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">v</span>

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">regexp</span>[<span class="ruby-value">:USERINFO</span>] <span class="ruby-operator">!~</span> <span class="ruby-identifier">v</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidComponentError</span>,
      <span class="ruby-node">&quot;bad component(expected userinfo component or user component): #{v}&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">return</span> <span class="ruby-keyword">true</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-check_userinfo" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">check_userinfo</span><span
                                class="method-args">(user, password = nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Checks the <code>user</code> and <code>password</code>.</p>

<p>If <code>password</code> is not provided, then <code>user</code> is split, using <a href="Generic.html#method-i-split_userinfo"><code>URI::Generic.split_userinfo</code></a>, to pull <code>user</code> and +password.</p>

<p>See also <a href="Generic.html#method-i-check_user"><code>URI::Generic.check_user</code></a>, <a href="Generic.html#method-i-check_password"><code>URI::Generic.check_password</code></a>.</p>

                              <div class="method-source-code" id="check_userinfo-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 375</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">check_userinfo</span>(<span class="ruby-identifier">user</span>, <span class="ruby-identifier">password</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">password</span>
    <span class="ruby-identifier">user</span>, <span class="ruby-identifier">password</span> = <span class="ruby-identifier">split_userinfo</span>(<span class="ruby-identifier">user</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">check_user</span>(<span class="ruby-identifier">user</span>)
  <span class="ruby-identifier">check_password</span>(<span class="ruby-identifier">password</span>, <span class="ruby-identifier">user</span>)

  <span class="ruby-keyword">return</span> <span class="ruby-keyword">true</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-escape_userpass" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">escape_userpass</span><span
                                class="method-args">(v)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Escapes ‘user:password’ <code>v</code> based on RFC 1738 section 3.1.</p>

                              <div class="method-source-code" id="escape_userpass-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 551</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">escape_userpass</span>(<span class="ruby-identifier">v</span>)
  <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">escape</span>(<span class="ruby-identifier">v</span>, <span class="ruby-regexp">/[@:\/]/o</span>) <span class="ruby-comment"># RFC 1738 section 3.1 #/</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-merge_path" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">merge_path</span><span
                                class="method-args">(base, rel)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Merges a base path <code>base</code>, with relative path <code>rel</code>, returns a modified base path.</p>

                              <div class="method-source-code" id="merge_path-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 1000</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">merge_path</span>(<span class="ruby-identifier">base</span>, <span class="ruby-identifier">rel</span>)

  <span class="ruby-comment"># RFC2396, Section 5.2, 5)</span>
  <span class="ruby-comment"># RFC2396, Section 5.2, 6)</span>
  <span class="ruby-identifier">base_path</span> = <span class="ruby-identifier">split_path</span>(<span class="ruby-identifier">base</span>)
  <span class="ruby-identifier">rel_path</span>  = <span class="ruby-identifier">split_path</span>(<span class="ruby-identifier">rel</span>)

  <span class="ruby-comment"># RFC2396, Section 5.2, 6), a)</span>
  <span class="ruby-identifier">base_path</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&#39;&#39;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">base_path</span>.<span class="ruby-identifier">last</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;..&#39;</span>
  <span class="ruby-keyword">while</span> <span class="ruby-identifier">i</span> = <span class="ruby-identifier">base_path</span>.<span class="ruby-identifier">index</span>(<span class="ruby-string">&#39;..&#39;</span>)
    <span class="ruby-identifier">base_path</span>.<span class="ruby-identifier">slice!</span>(<span class="ruby-identifier">i</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>, <span class="ruby-value">2</span>)
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">if</span> (<span class="ruby-identifier">first</span> = <span class="ruby-identifier">rel_path</span>.<span class="ruby-identifier">first</span>) <span class="ruby-keyword">and</span> <span class="ruby-identifier">first</span>.<span class="ruby-identifier">empty?</span>
    <span class="ruby-identifier">base_path</span>.<span class="ruby-identifier">clear</span>
    <span class="ruby-identifier">rel_path</span>.<span class="ruby-identifier">shift</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-comment"># RFC2396, Section 5.2, 6), c)</span>
  <span class="ruby-comment"># RFC2396, Section 5.2, 6), d)</span>
  <span class="ruby-identifier">rel_path</span>.<span class="ruby-identifier">push</span>(<span class="ruby-string">&#39;&#39;</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">rel_path</span>.<span class="ruby-identifier">last</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;.&#39;</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">rel_path</span>.<span class="ruby-identifier">last</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;..&#39;</span>
  <span class="ruby-identifier">rel_path</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-string">&#39;.&#39;</span>)

  <span class="ruby-comment"># RFC2396, Section 5.2, 6), e)</span>
  <span class="ruby-identifier">tmp</span> = []
  <span class="ruby-identifier">rel_path</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">x</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;..&#39;</span> <span class="ruby-operator">&amp;&amp;</span>
        <span class="ruby-operator">!</span>(<span class="ruby-identifier">tmp</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">tmp</span>.<span class="ruby-identifier">last</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;..&#39;</span>)
      <span class="ruby-identifier">tmp</span>.<span class="ruby-identifier">pop</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">tmp</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">x</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">add_trailer_slash</span> = <span class="ruby-operator">!</span><span class="ruby-identifier">tmp</span>.<span class="ruby-identifier">empty?</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">base_path</span>.<span class="ruby-identifier">empty?</span>
    <span class="ruby-identifier">base_path</span> = [<span class="ruby-string">&#39;&#39;</span>] <span class="ruby-comment"># keep &#39;/&#39; for root directory</span>
  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">add_trailer_slash</span>
    <span class="ruby-identifier">base_path</span>.<span class="ruby-identifier">pop</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">while</span> <span class="ruby-identifier">x</span> = <span class="ruby-identifier">tmp</span>.<span class="ruby-identifier">shift</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">x</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;..&#39;</span>
      <span class="ruby-comment"># RFC2396, Section 4</span>
      <span class="ruby-comment"># a .. or . in an absolute path has no special meaning</span>
      <span class="ruby-identifier">base_path</span>.<span class="ruby-identifier">pop</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">base_path</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">1</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-comment"># if x == &#39;..&#39;</span>
      <span class="ruby-comment">#   valid absolute (but abnormal) path &quot;/../...&quot;</span>
      <span class="ruby-comment"># else</span>
      <span class="ruby-comment">#   valid absolute path</span>
      <span class="ruby-comment"># end</span>
      <span class="ruby-identifier">base_path</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">x</span>
      <span class="ruby-identifier">tmp</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">t</span><span class="ruby-operator">|</span> <span class="ruby-identifier">base_path</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">t</span>}
      <span class="ruby-identifier">add_trailer_slash</span> = <span class="ruby-keyword">false</span>
      <span class="ruby-keyword">break</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">base_path</span>.<span class="ruby-identifier">push</span>(<span class="ruby-string">&#39;&#39;</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">add_trailer_slash</span>

  <span class="ruby-keyword">return</span> <span class="ruby-identifier">base_path</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&#39;/&#39;</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-replace-21" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">replace!</span><span
                                class="method-args">(oth)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Replaces self by other <a href="../URI.html"><code>URI</code></a> object.</p>

                              <div class="method-source-code" id="replace-21-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 299</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">replace!</span>(<span class="ruby-identifier">oth</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">oth</span>.<span class="ruby-identifier">class</span>
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">&quot;expected #{self.class} object&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">component</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">__send__</span>(<span class="ruby-node">&quot;#{c}=&quot;</span>, <span class="ruby-identifier">oth</span>.<span class="ruby-identifier">__send__</span>(<span class="ruby-identifier">c</span>))
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-split_path" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">split_path</span><span
                                class="method-args">(path)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns an Array of the path split on ‘/’.</p>

                              <div class="method-source-code" id="split_path-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 991</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">split_path</span>(<span class="ruby-identifier">path</span>)
  <span class="ruby-identifier">path</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">&quot;/&quot;</span>, <span class="ruby-value">-1</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-split_userinfo" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">split_userinfo</span><span
                                class="method-args">(ui)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the userinfo <code>ui</code> as <code>[user, password]</code> if properly formatted as ‘user:password’.</p>

                              <div class="method-source-code" id="split_userinfo-source">
            <pre><span class="ruby-comment"># File uri/generic.rb, line 542</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">split_userinfo</span>(<span class="ruby-identifier">ui</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span>, <span class="ruby-keyword">nil</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">ui</span>
  <span class="ruby-identifier">user</span>, <span class="ruby-identifier">password</span> = <span class="ruby-identifier">ui</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">&#39;:&#39;</span>, <span class="ruby-value">2</span>)

  <span class="ruby-keyword">return</span> <span class="ruby-identifier">user</span>, <span class="ruby-identifier">password</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>. </p><p><a href="https://jamesbritt.bandcamp.com/">Hack your world.  Feed your head.  Live curious</a>.</p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

